package com.funtl.spring.cloud.alibaba.unit.service;

import com.funtl.spring.cloud.alibaba.unit.pojo.SysUser;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName SysUserService
 * @Description TODO
 * @Author Mr.Starry
 * @Date 2020/1/5 17:04
 * @Version 1.0
 */
@Service
public class SysUserService {

    private static Map<String, SysUser> userMap = new HashMap<>();

    // 在当前的这个bean构造完之后，执行该代码
    @PostConstruct
    public void init() {
        SysUser sysUser = new SysUser();
        sysUser.setId(1);
        sysUser.setUsername("jack");
        sysUser.setPassword("$2a$10$aio1nF/uRmomk6pWRlRsruJ4xdxJ8xMocvuC/euem9zGjzgij35Le");

        userMap.put("jack", sysUser);
    }

    public SysUser getSysUserByUsername(String username) {
        return userMap.get(username);
    }
}
